#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
void* a(void*);
void* b(void*);
void* c(void*);
sem_t sem1,sem2;
int main(void)
{
	// 按照 c->b->a 的顺序执行
	sem_init(&sem1,0,0);
	sem_init(&sem2,0,0);
	pthread_t thread_a,thread_b,thread_c;
	pthread_create(&thread_a,NULL,a,(void*)NULL);
	pthread_create(&thread_b,NULL,b,(void*)NULL);
	pthread_create(&thread_c,NULL,c,(void*)NULL);
	pthread_join(thread_a,NULL);
	pthread_join(thread_b,NULL);
	pthread_join(thread_c,NULL);
	return 0;
}
void* a(void* data)
{
	sem_wait(&sem1);
	printf("func a\n");
	return (void*)NULL;
}
void* b(void* data)
{
	sem_wait(&sem2);
	sem_post(&sem1);
	printf("func b\n");
	return (void*)NULL;
}
void* c(void* data)
{
	sem_post(&sem2);
	printf("func c\n");
	return (void*)NULL;

